package com.rm.zeyou.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.rm.zeyou.entity.User;
import com.rm.zeyou.response.ApiRestResponse;
import com.rm.zeyou.service.CityVoteService;
import com.rm.zeyou.util.login.LoginUtil;
import com.rm.zeyou.vo.request.AddCityVoteVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 城市投票表 前端控制器
 * </p>
 *
 * @author YanYang
 * @since 2025-03-14 17:20:22
 */
@Api(tags = "城市投票")
@RestController
@RequestMapping("/api/cityVote")
public class CityVoteController {
    @Resource
    private CityVoteService cityVoteService;
    @Resource
    private LoginUtil loginUtil;

    @ApiOperation(value = "城市投票")
    @PostMapping("addCityVote")
    @SaCheckLogin(type = "user")
    public ApiRestResponse<Integer> addCityVote(@RequestBody AddCityVoteVo addVo) {
        User user = loginUtil.getUser();
        return cityVoteService.addCityVote(user.getId(),addVo);
    }

}
